package net.oschina.android.adapter;

import net.oschina.android.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * @author HuangWenwei
 *
 * @date 2014年9月9日
 */
public class lasttweetadapter extends BaseAdapter {
	
	private int mCount = 20;
	private final LayoutInflater mLayoutInflate;
	private final String mPositionString;
	private final int mTextViewResourceId;

	/**
	 * @param mTextViewResourceId
	 */
	public lasttweetadapter(Context context,int mTextViewResourceId) {
		mLayoutInflate = LayoutInflater.from(context);
		mPositionString = context.getString(R.string.position) + " ";
		this.mTextViewResourceId = mTextViewResourceId;
	}

	public void addMoreItems(int count){
		mCount +=count;
		notifyDataSetChanged();
	}
	@Override
	public int getCount() {
		return mCount;
	}

	@Override
	public Object getItem(int position) {
		return mPositionString+position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final TextView tv;
		if(convertView ==null)
			tv = (TextView) mLayoutInflate.inflate(mTextViewResourceId, null);
		else
			tv = (TextView) convertView;
		tv.setText((CharSequence) getItem(position));
		return tv;
	}
}
